package com.fairytask.stage
{
	import com.fairytask.data.Modulator;
	import com.fairytask.event.BattleEvent;
	import com.fairytask.logic.BattleLogic;
	import com.fairytask.logic.LoginLogic;
	import com.fairytask.screen.MainScreen;
	
	import Box2D.Common.Math.b2Vec2;
	
	import citrus.core.starling.StarlingState;
	import citrus.objects.Box2DPhysicsObject;
	import citrus.physics.box2d.Box2D;
	
	import feathers.themes.MetalWorksMobileTheme;
	
	import starling.display.Sprite;
	import starling.events.Event;

	/**
	 * 游戏场景 
	 * @author game
	 * 
	 */	
	public class GameStage extends StarlingState
	{
		//定义显示层次
		private var normalSpace	:MainScreen;
		private var effectSpace	:Sprite;
		private var uiSpace			:Sprite;
		//数据
		private var model			:Modulator;
		
		private var theme	:MetalWorksMobileTheme;
		public function GameStage()
		{
			super();
			model	=	Modulator.instance;
			
			this.addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		/**
		 * 添加到游戏场景 
		 * @param evt
		 * 
		 */
		private function onAdded(evt:Event):void
		{
			//初始化皮肤
			theme	=	new MetalWorksMobileTheme(this.stage);
		}
		
		/**
		 * 重写初始化 
		 */
		override public function initialize():void
		{
			super.initialize();
			
			normalSpace	=	new MainScreen();
			uiSpace	=	new Sprite();
			effectSpace	=	new Sprite();
			//添加显示层次
			stage.addChild(normalSpace);
			stage.addChild(uiSpace);
			stage.addChild(effectSpace);
			//加载资源
			//逻辑初始化
			initLogic();
			
			//测试用 进入战斗
			model.dispatchEvent(new BattleEvent(BattleEvent.ENTER_BATTLE));
		}
		
		/**
		 * 游戏逻辑初始化 
		 */
		private function initLogic():void
		{
			LoginLogic.instance;
			BattleLogic.instance;
		}
	}
}